import Mock from 'mockjs'
import { SUCCESS_CODE } from '@/constants'
import { toAnyString } from '@/utils'

const timeout = 1000

const adminList = [
  {
    path: '/dashboard',
    component: '#',
    redirect: '/dashboard/analysis',
    name: 'Dashboard',
    meta: {
      title: 'router.dashboard',
      icon: 'vi-ant-design:dashboard-filled'
    },
    children: [
      {
        path: 'analysis',
        component: 'views/Dashboard/Analysis',
        name: 'Analysis',
        meta: {
          icon: 'vi-ant-design:dashboard-filled',
          title: '首页',
          noCache: true,
          affix: true
        }
      }
    ]
  },
  {
    path: '/setup',
    component: '#',
    redirect: '/setup/setupSearch',
    name: 'Setup',
    meta: {
      title: '快速搭建',
      icon: 'vi-bx:bxs-component',
      alwaysShow: true
    },
    children: [
      {
        path: 'setupSearch',
        component: 'views/SetupPageConfig/setupSearch',
        name: 'SetupSearch',
        meta: {
          title: '搭建搜索栏'
        }
      },
      {
        path: 'setupDetail',
        component: 'views/SetupPageConfig/setupDetail',
        name: 'SetupDetail',
        meta: {
          title: '搭建详情页'
        }
      },
      {
        path: 'setupForm',
        component: 'views/SetupPageConfig/setupForm',
        name: 'SetupForm',
        meta: {
          title: '搭建表单'
        }
      },
      {
        path: 'setupTable',
        component: 'views/SetupPageConfig/setupTable',
        name: 'SetupTable',
        meta: {
          title: '搭建表格'
        }
      },
      {
        path: 'setupAllSchemas',
        component: 'views/SetupPageConfig/setupAllSchemas',
        name: 'SetupAllSchemas',
        meta: {
          title: '搭建组合配置项'
        }
      }
    ]
  },
  {
    path: '/Threejs',
    component: '#',
    redirect: '/Threejs/index',
    name: 'Threejs',
    meta: {
      title: '三维菜单',
      icon: 'vi-bx:bxs-component',
      alwaysShow: true
    },
    children: [
      {
        path: 'Threejs/index1',
        component: 'views/Threejs/index',
        name: 'Threejs1',
        meta: {
          title: '三维菜单1'
        }
      },
      {
        path: 'Threejs/index2',
        component: 'views/Threejs/index2',
        name: 'Threejs2',
        meta: {
          title: '三维菜单2'
        }
      }
    ]
  },
  {
    path: '/traffic',
    component: '#',
    redirect: '/traffic/RoadManagement',
    name: 'Traffic',
    meta: {
      title: '交通事件管理',
      icon: 'vi-bx:bxs-component',
      alwaysShow: true
    },
    children: [
      {
        path: 'road',
        component: 'views/Traffic/RoadManagement/roadManagement',
        name: 'RoadManagement',
        meta: {
          title: '路段管理'
        }
      },
      {
        path: 'pile',
        component: 'views/Traffic/PileManagement/pileManagement',
        name: 'PileManagement',
        meta: {
          title: '桩号管理'
        }
      },
      {
        path: 'city',
        component: 'views/Traffic/CityManagement/cityManagement',
        name: 'CityManagement',
        meta: {
          title: '城市管理'
        }
      }
    ]
  },
  {
    path: '/Device',
    component: '#',
    redirect: '/Device/facility',
    name: 'Device',
    meta: {
      title: '设备资产管理',
      icon: 'vi-bx:bxs-component',
      alwaysShow: true
    },
    children: [
      {
        path: 'facility',
        component: 'views/Device/Facility/facility',
        name: 'Facility',
        meta: {
          title: '设备资产列表'
        }
      },
      {
        path: 'statistic',
        component: '##',
        redirect: '/Device/statistic/facility',
        name: 'Statistic',
        meta: {
          title: '资产统计分析',
          icon: 'vi-bx:bxs-component',
          alwaysShow: true
        },
        children: [
          {
            path: 'facility',
            name: 'FacilityStatisticAnalysis',
            component: 'views/Device/FacilityStatisticAnalysis/facilityStatisticAnalysis',
            status: Mock.Random.integer(0, 1),
            permission: ['edit', 'add', 'delete'],
            meta: {
              title: '按设施分类',
              permission: ['edit', 'add', 'delete']
            }
          },
          {
            path: 'road',
            name: 'RoadStatisticAnalysis',
            component: 'views/Device/FacilityStatisticAnalysis/roadStatisticAnalysis',
            status: Mock.Random.integer(0, 1),
            permission: ['edit', 'add', 'delete'],
            meta: {
              title: '按路段分类',
              permission: ['edit', 'add', 'delete']
            }
          },
          {
            path: 'device',
            name: 'DeviceStatisticAnalysis',
            component: 'views/Device/FacilityStatisticAnalysis/deviceStatisticAnalysis',
            status: Mock.Random.integer(0, 1),
            permission: ['edit', 'add', 'delete'],
            meta: {
              title: '机电设备分类',
              permission: ['edit', 'add', 'delete']
            }
          }
        ]
      },
      {
        path: 'monitor',
        component: 'views/Device/OperationMonitoring/operationMonitoring',
        name: 'Monitor',
        meta: {
          title: '设备运行监测'
        }
      },
      {
        path: 'preserve',
        component: 'views/Device/PreserveList/preserveList',
        name: 'PreserveList',
        meta: {
          title: '设备检定列表'
        }
      }
    ]
  }
]

const testList = [
  {
    path: '/resource',
    component: '#',
    redirect: '/resource/enterprise-resource',
    name: 'ResourceManagement',
    meta: {
      title: '用户与权限管理',
      icon: 'vi-ep:management',
      alwaysShow: true
    },
    children: [
      {
        path: 'enterprise-resource',
        component: 'views/BackstageView/EnterpriseResource/enterpriseResource',
        name: 'EnterpriseResource',
        title: '资源管理',
        meta: {
          title: '资源管理',
          noCache: true,
          affix: true
        }
      },
      {
        path: 'user-management',
        component: 'views/BackstageView/UserManagement/userManagement',
        name: 'UserManagement',
        title: '用户管理',
        meta: {
          title: '用户管理'
        }
      },
      {
        path: 'role-management',
        component: 'views/BackstageView/Role/RoleManagement',
        name: 'RoleManagement',
        title: '角色管理',
        meta: {
          title: '角色管理'
        }
      },
      {
        path: 'department-management',
        component: 'views/BackstageView/Department/departmentManagement',
        name: 'DepartmentManagement',
        title: '部门管理',
        meta: {
          title: '部门管理'
        }
      },
      {
        path: 'sys-org-management',
        component: 'views/BackstageView/SysOrg/sysOrgManagement',
        name: 'SysOrgManagement',
        title: '机构管理',
        meta: {
          title: '机构管理'
        }
      },
      {
        path: 'log-list',
        component: 'views/BackstageView/LogList/logList',
        name: 'LogList',
        title: '日志查询',
        meta: {
          title: '日志查询'
        }
      }
    ]
  }
]

const List: any[] = []

const roleNames = ['超级管理员', '管理员', '普通用户', '游客']
const menus = [
  [
    {
      path: '/dashboard',
      component: '#',
      redirect: '/dashboard/analysis',
      name: 'Dashboard',
      status: Mock.Random.integer(0, 1),
      id: 1,
      meta: {
        title: '首页',
        icon: 'vi-ant-design:dashboard-filled',
        alwaysShow: true
      },
      children: [
        {
          path: 'analysis',
          component: 'views/Dashboard/Analysis',
          name: 'Analysis',
          status: Mock.Random.integer(0, 1),
          id: 2,
          meta: {
            title: '分析页',
            noCache: true
          }
        },
        {
          path: 'workplace',
          component: 'views/Dashboard/Workplace',
          name: 'Workplace',
          status: Mock.Random.integer(0, 1),
          id: 3,
          meta: {
            title: '工作台',
            noCache: true
          }
        }
      ]
    },
    {
      path: '/external-link',
      component: '#',
      meta: {
        title: '文档',
        icon: 'vi-clarity:document-solid'
      },
      name: 'ExternalLink',
      status: Mock.Random.integer(0, 1),
      id: 4,
      children: [
        {
          path: 'https://element-plus-admin-doc.cn/',
          name: 'DocumentLink',
          status: Mock.Random.integer(0, 1),
          id: 5,
          meta: {
            title: '文档'
          }
        }
      ]
    },
    {
      path: '/level',
      component: '#',
      redirect: '/level/menu1/menu1-1/menu1-1-1',
      name: 'Level',
      status: Mock.Random.integer(0, 1),
      id: 6,
      meta: {
        title: '菜单',
        icon: 'vi-carbon:skill-level-advanced'
      },
      children: [
        {
          path: 'menu1',
          name: 'Menu1',
          component: '##',
          status: Mock.Random.integer(0, 1),
          id: 7,
          redirect: '/level/menu1/menu1-1/menu1-1-1',
          meta: {
            title: '菜单1'
          },
          children: [
            {
              path: 'menu1-1',
              name: 'Menu11',
              component: '##',
              status: Mock.Random.integer(0, 1),
              id: 8,
              redirect: '/level/menu1/menu1-1/menu1-1-1',
              meta: {
                title: '菜单1-1',
                alwaysShow: true
              },
              children: [
                {
                  path: 'menu1-1-1',
                  name: 'Menu111',
                  component: 'views/Level/Menu111',
                  status: Mock.Random.integer(0, 1),
                  id: 9,
                  permission: ['edit', 'add', 'delete'],
                  meta: {
                    title: '菜单1-1-1',
                    permission: ['edit', 'add', 'delete']
                  }
                }
              ]
            },
            {
              path: 'menu1-2',
              name: 'Menu12',
              component: 'views/Level/Menu12',
              status: Mock.Random.integer(0, 1),
              id: 10,
              permission: ['edit', 'add', 'delete'],
              meta: {
                title: '菜单1-2',
                permission: ['edit', 'add', 'delete']
              }
            }
          ]
        },
        {
          path: 'menu2',
          name: 'Menu2Demo',
          component: 'views/Level/Menu2',
          status: Mock.Random.integer(0, 1),
          id: 11,
          permission: ['edit', 'add', 'delete'],
          meta: {
            title: '菜单2',
            permission: ['edit', 'add', 'delete']
          }
        }
      ]
    },
    {
      path: '/example',
      component: '#',
      redirect: '/example/example-dialog',
      name: 'Example',
      status: Mock.Random.integer(0, 1),
      id: 12,
      meta: {
        title: '综合示例',
        icon: 'vi-ep:management',
        alwaysShow: true
      },
      children: [
        {
          path: 'example-dialog',
          component: 'views/Example/Dialog/ExampleDialog',
          name: 'ExampleDialog',
          status: Mock.Random.integer(0, 1),
          id: 13,
          permission: ['edit', 'add', 'delete'],
          meta: {
            title: '综合示例-弹窗',
            permission: ['edit', 'add', 'delete']
          }
        },
        {
          path: 'example-page',
          component: 'views/Example/Page/ExamplePage',
          name: 'ExamplePage',
          status: Mock.Random.integer(0, 1),
          id: 14,
          permission: ['edit', 'add', 'delete'],
          meta: {
            title: '综合示例-页面',
            permission: ['edit', 'add', 'delete']
          }
        },
        {
          path: 'example-add',
          component: 'views/Example/Page/ExampleAdd',
          name: 'ExampleAdd',
          status: Mock.Random.integer(0, 1),
          id: 15,
          permission: ['edit', 'add', 'delete'],
          meta: {
            title: '综合示例-新增',
            noTagsView: true,
            noCache: true,
            hidden: true,
            showMainRoute: true,
            activeMenu: '/example/example-page',
            permission: ['edit', 'add', 'delete']
          }
        },
        {
          path: 'example-edit',
          component: 'views/Example/Page/ExampleEdit',
          name: 'ExampleEdit',
          status: Mock.Random.integer(0, 1),
          id: 16,
          permission: ['edit', 'add', 'delete'],
          meta: {
            title: '综合示例-编辑',
            noTagsView: true,
            noCache: true,
            hidden: true,
            showMainRoute: true,
            activeMenu: '/example/example-page',
            permission: ['edit', 'add', 'delete']
          }
        },
        {
          path: 'example-detail',
          component: 'views/Example/Page/ExampleDetail',
          name: 'ExampleDetail',
          status: Mock.Random.integer(0, 1),
          id: 17,
          permission: ['edit', 'add', 'delete'],
          meta: {
            title: '综合示例-详情',
            noTagsView: true,
            noCache: true,
            hidden: true,
            showMainRoute: true,
            activeMenu: '/example/example-page',
            permission: ['edit', 'add', 'delete']
          }
        }
      ]
    }
  ],
  [
    {
      path: '/dashboard',
      component: '#',
      redirect: '/dashboard/analysis',
      name: 'Dashboard',
      status: Mock.Random.integer(0, 1),
      id: 1,
      meta: {
        title: '首页',
        icon: 'vi-ant-design:dashboard-filled',
        alwaysShow: true
      },
      children: [
        {
          path: 'analysis',
          component: 'views/Dashboard/Analysis',
          name: 'Analysis',
          status: Mock.Random.integer(0, 1),
          id: 2,
          meta: {
            title: '分析页',
            noCache: true
          }
        },
        {
          path: 'workplace',
          component: 'views/Dashboard/Workplace',
          name: 'Workplace',
          status: Mock.Random.integer(0, 1),
          id: 3,
          meta: {
            title: '工作台',
            noCache: true
          }
        }
      ]
    }
  ],
  [
    {
      path: '/external-link',
      component: '#',
      meta: {
        title: '文档',
        icon: 'vi-clarity:document-solid'
      },
      name: 'ExternalLink',
      status: Mock.Random.integer(0, 1),
      id: 4,
      children: [
        {
          path: 'https://element-plus-admin-doc.cn/',
          name: 'DocumentLink',
          status: Mock.Random.integer(0, 1),
          id: 5,
          meta: {
            title: '文档'
          }
        }
      ]
    },
    {
      path: '/level',
      component: '#',
      redirect: '/level/menu1/menu1-1/menu1-1-1',
      name: 'Level',
      status: Mock.Random.integer(0, 1),
      id: 6,
      meta: {
        title: '菜单',
        icon: 'vi-carbon:skill-level-advanced'
      },
      children: [
        {
          path: 'menu1',
          name: 'Menu1',
          component: '##',
          status: Mock.Random.integer(0, 1),
          id: 7,
          redirect: '/level/menu1/menu1-1/menu1-1-1',
          meta: {
            title: '菜单1'
          },
          children: [
            {
              path: 'menu1-1',
              name: 'Menu11',
              component: '##',
              status: Mock.Random.integer(0, 1),
              id: 8,
              redirect: '/level/menu1/menu1-1/menu1-1-1',
              meta: {
                title: '菜单1-1',
                alwaysShow: true
              },
              children: [
                {
                  path: 'menu1-1-1',
                  name: 'Menu111',
                  component: 'views/Level/Menu111',
                  status: Mock.Random.integer(0, 1),
                  id: 9,
                  permission: ['edit', 'add', 'delete'],
                  meta: {
                    title: '菜单1-1-1',
                    permission: ['edit', 'add', 'delete']
                  }
                }
              ]
            },
            {
              path: 'menu1-2',
              name: 'Menu12',
              component: 'views/Level/Menu12',
              status: Mock.Random.integer(0, 1),
              id: 10,
              permission: ['edit', 'add', 'delete'],
              meta: {
                title: '菜单1-2',
                permission: ['edit', 'add', 'delete']
              }
            }
          ]
        },
        {
          path: 'menu2',
          name: 'Menu2Demo',
          component: 'views/Level/Menu2',
          status: Mock.Random.integer(0, 1),
          id: 11,
          permission: ['edit', 'add', 'delete'],
          meta: {
            title: '菜单2',
            permission: ['edit', 'add', 'delete']
          }
        }
      ]
    }
  ],
  [
    {
      path: '/example',
      component: '#',
      redirect: '/example/example-dialog',
      name: 'Example',
      status: Mock.Random.integer(0, 1),
      id: 12,
      meta: {
        title: '综合示例',
        icon: 'vi-ep:management',
        alwaysShow: true
      },
      children: [
        {
          path: 'example-detail',
          component: 'views/Example/Page/ExampleDetail',
          name: 'ExampleDetail',
          status: Mock.Random.integer(0, 1),
          id: 17,
          permission: ['edit', 'add', 'delete'],
          meta: {
            title: '综合示例-详情',
            noTagsView: true,
            noCache: true,
            hidden: true,
            showMainRoute: true,
            activeMenu: '/example/example-page',
            permission: ['edit', 'add', 'delete']
          }
        }
      ]
    }
  ]
]

for (let i = 0; i < 4; i++) {
  List.push(
    Mock.mock({
      id: toAnyString(),
      // timestamp: +Mock.Random.date('T'),
      roleName: roleNames[i],
      role: '@first',
      status: Mock.Random.integer(0, 1),
      createTime: '@datetime',
      remark: '@cword(10, 15)',
      menu: menus[i]
    })
  )
}

export default [
  // 列表接口
  {
    url: '/mock/role/list',
    method: 'get',
    timeout,
    response: () => {
      return {
        code: SUCCESS_CODE,
        data: adminList
      }
    }
  },
  {
    url: '/mock/role/table',
    method: 'get',
    timeout,
    response: () => {
      return {
        code: SUCCESS_CODE,
        data: {
          list: List,
          total: 4
        }
      }
    }
  },
  // 列表接口
  {
    url: '/mock/role/list2',
    method: 'get',
    timeout,
    response: () => {
      return {
        code: SUCCESS_CODE,
        data: testList
      }
    }
  },
  {
    url: '/mock/role/table',
    method: 'get',
    timeout,
    response: () => {
      return {
        code: SUCCESS_CODE,
        data: {
          list: List,
          total: 4
        }
      }
    }
  }
]
